import socket

def send_udp_message(message, ipv6_address, port):
    # 创建 IPv6 UDP socket
    sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
    
    try:
        # 发送消息到指定的 IPv6 地址和端口
        sock.sendto(message.encode(), (ipv6_address, port))
        print("UDP 消息已发送到", ipv6_address, "端口", port)
    finally:
        # 关闭 socket 连接
        sock.close()

# 使用函数
send_udp_message("Hello, UDP!", r"fe80::6462:ad3a:227a:e6d%eth0", 8887)